package com.bishe.demo.modules.common.controller;

import com.bishe.demo.modules.common.dao.BaiduMapCityDao;
import com.bishe.demo.modules.common.dao.CityDao;
import com.bishe.demo.modules.common.entity.BaiduMapCity;
import com.bishe.demo.modules.common.entity.City;
import com.bishe.demo.modules.common.entity.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description BaiduMapCityController
 * @Author Lubb
 * @Date 2021/4/2 16:06
 */
@RestController
public class BaiduMapCityController {
    @Autowired
    private BaiduMapCityDao baiduMapCityDao;
    @Autowired
    private CityDao cityDao;

    @PutMapping("/api/updateCityCoordinate")
    public ResultEntity<List<City>> updateCityCoordinate(@RequestBody List<BaiduMapCity> municipalities){
        for (BaiduMapCity baiduMapCity : municipalities) {
            baiduMapCityDao.updateCityCoordinate(baiduMapCity);
        }
        return new ResultEntity<List<City>>(ResultEntity.ResultStatus.SUCCESS.code,"success",
                cityDao.getCitiesByPid(0));
    }
}
